|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectcontrolP5.Controller
controlP5.Button
controlP5.MultiListButton
public class MultiListButton
/**
* ControlP5 MultiList
* by andreas schlegel, 2009
*/
import controlP5.*;
ControlP5 controlP5;
MultiList l;
void setup() {
size(400,400);
frameRate(30);
controlP5 = new ControlP5(this);
// add a multiList to controlP5.
// elements of the list have default dimensions
// here, a width of 100 and a height of 12
l = controlP5.addMultiList("myList",0,10,100,12);
// create a multiListButton which we will use to
// add new buttons to the multilist
MultiListButton b;
b = l.add("level1",1);
// add items to a sublist of button "level1"
b.add("level11",11).setLabel("level1 item1");
b.add("level12",12).setLabel("level1 item2");
b = l.add("level2",2);
int cnt = 100;
// add some more sublists.
for(int i=0;i<10;i++) {
MultiListButton c = b.add("level2"+(i+1),20+i+1);
c.setLabel("level2 item"+(i+1));
c.setColorBackground(color(64 + 18*i,0,0));
if(i==4) {
// changing the width and the height of a button
// will be inherited by its sublists.
c.setWidth(100);
c.setHeight(20);
}
cnt++;
if(i==4) {
for(int j=0;j<10;j++) {
cnt++;
MultiListButton d;
d = c.add("level2"+i+""+j,250+j+1);
d.setLabel("level2 item"+(i+1)+" "+"item"+(j+1));
d.setColorBackground(color(64 + 18*j,(64 + 18*j)/2,0));
d.setId(cnt);
d.setWidth(200);
}
}
}
MultiListButton cc = (MultiListButton)controlP5.controller("level21");
cc.setHeight(40);
}
void controlEvent(ControlEvent theEvent) {
println(theEvent.controller().name()+" = "+theEvent.value());
// uncomment the line below to remove a multilist item when clicked.
// theEvent.controller().remove();
}
void draw() {
background(0);
}
void keyPressed() {
if(controlP5.controller("level23")!=null) {
println("removing multilist button level23.");
controlP5.controller("level23").remove();
}
}
| Field Summary |
|---|
| Fields inherited from interface controlP5.ControlP5Constants |
|---|
acceptClassList, ACTIVE, ALT, ARC, ARRAY, BACKSPACE, BOOLEAN, BOTTOM, CENTER, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IMAGE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LINE, LOAD, MENU, METHOD, MOVE, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, SAVE, SHIFT, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TWO_PI, UP, VERBOSE, VERTICAL |
| Method Summary | |
|---|---|
MultiListButton |
add(java.lang.String theName,
float theValue)
add a new button to the sublist of this multilist button. |
void |
addToXMLElement(ControlP5XMLElement theElement)
|
void |
close()
|
void |
close(MultiListInterface theInterface)
|
int |
getDirection()
|
void |
mouseReleasedOutside()
|
boolean |
observe()
|
void |
open()
|
void |
remove()
remove a controller from controlP5. |
Controller |
setHeight(int theHeight)
set the height of a multlist button. |
Controller |
setWidth(int theWidth)
set the width of a multlist button. |
java.util.List<Controller> |
subelements()
|
void |
updateLocation(float theX,
float theY)
|
void |
updateRect(float theX,
float theY,
float theW,
float theH)
|
| Methods inherited from class controlP5.Button |
|---|
activateBy, booleanValue, mousePressed, mouseReleased, setOff, setOn, setSwitch, setValue, toString, update, updateDisplayMode |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface controlP5.MultiListInterface |
|---|
draw, name |
| Method Detail |
|---|
public void remove()
Controller
remove in interface ControllerInterfaceremove in class Controllerpublic java.util.List<Controller> subelements()
subelements in interface MultiListInterfacepublic int getDirection()
getDirection in interface MultiListInterface
public void updateRect(float theX,
float theY,
float theW,
float theH)
theX - floattheY - floattheW - floattheH - float
public void updateLocation(float theX,
float theY)
updateLocation in interface MultiListInterfacetheX - floattheY - floatpublic Controller setWidth(int theWidth)
setWidth in class ControllertheWidth - intpublic Controller setHeight(int theHeight)
setHeight in class ControllertheHeight - int
public MultiListButton add(java.lang.String theName,
float theValue)
theName - StringtheValue - int
public void mouseReleasedOutside()
Button
mouseReleasedOutside in class Buttonpublic boolean observe()
observe in interface MultiListInterfacetheMousePosition - CVector3f
public void close(MultiListInterface theInterface)
close in interface MultiListInterfacetheInterface - MultiListInterfacepublic void close()
close in interface MultiListInterfacepublic void open()
open in interface MultiListInterfacepublic void addToXMLElement(ControlP5XMLElement theElement)
Button
addToXMLElement in interface ControllerInterfaceaddToXMLElement in interface MultiListInterfaceaddToXMLElement in class ButtontheElement - ControlP5XMLElement
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||